package com.miniserver.util;

import org.apache.log4j.DailyRollingFileAppender;
import org.apache.log4j.Priority;
/**
 * 控制log4j日志输出到不同的类别中 
 * @author zzlt104
 *
 */
public class MyDailyRollingFileAppender extends DailyRollingFileAppender {
	String thresholdLevel;
	int _level;
	public String getThresholdLevel() {
		return thresholdLevel;
	}
	public void setThresholdLevel(String thresholdLevel)
	{
		this.thresholdLevel = thresholdLevel;
		switch(thresholdLevel.toLowerCase())
		{
			case "debug":
			{
				this._level = Priority.DEBUG_INT;
			 break;
			}
			case "info":
			{
				this._level = Priority.INFO_INT;
			 break;
			}
			case "warn":
			{
				this._level = Priority.WARN_INT;
			 break;
			}
			case "trace":
			{
				this._level = org.apache.log4j.Level.TRACE_INT;
			 break;
			}
			case "error":
			{
				this._level = Priority.ERROR_INT;
			 break;
			}
			case "paysuccess":
			{
				this._level = Priority.INFO_INT+50;
			 break;
			}
			case "paywarn":
			{
				this._level = Priority.ERROR_INT+50;
			 break;
			}
			case "costlog":
			{
				this._level = Priority.INFO_INT + 100;
				break;
			}
		}		
	}
	@Override
	public boolean isAsSevereAsThreshold(Priority priority) {	
		// 只判断是否相等，而不判断优先级
		return this._level==priority.toInt();		
	}
	
}
